const jwt = require('jsonwebtoken')
const utils = require('utility')

const Config = {
    secretSalt: 'YIKESAITING'
}

const Util = {
    setToken:(payload, expirationTime)=>{
        return jwt.sign(payload, Config.secretSalt, { expiresIn: expirationTime })
    },
    checkToken: async(token) => {
       const getAfterCheckTokenRes = await jwt.verify(token, Config.secretSalt)
       return getAfterCheckTokenRes
    },
    md5Pwd(pwd){
        const salt = 'i345fierfaih345z43q'
        return utils.md5(utils.md5(pwd + salt))
    },
    createUserCode(username){
        const salt = 'excited+1s'
        return utils.md5(utils.md5(username + salt))
    }
}

module.exports ={
    Util
}


